package org.yly.game.rpggame.domain.model;

import java.util.Map;
import java.util.Set;
/**
 * 升级配置
 * @author makefu
 *
 */
public class UpgradeConfig {

	private Map<Integer,UpgradeInfo> upgradeMap;
	
	
	public UpgradeConfig(Set<UpgradeInfo> upgradeSet) {
		for (UpgradeInfo vo : upgradeSet){
			upgradeMap.put(vo.level, vo);
		}
	}
	
	public UpgradeInfo getUpgradeConfig(int level) {
		return upgradeMap.get(level);
	}
	
	public UpgradeInfo getUpgradeConfigByValue(int value) {
		UpgradeInfo upgradeInfo = new UpgradeInfo();
		for (UpgradeInfo info : upgradeMap.values()) {
			if (value >= info.needValue && upgradeInfo.needValue < info.needValue) {
				upgradeInfo = info;
			}
		}
		return upgradeInfo;
	}
	
	public class UpgradeInfo {
		public int level; // 当前等级
		public int needValue;
	}
	
}
